package com.daiyang.lotterysystem.common.errorexception;

import com.daiyang.lotterysystem.common.errorcode.ControllerErrorCodeConstants;
import com.daiyang.lotterysystem.common.errorcode.ErrorCode;
import lombok.Data;
import lombok.EqualsAndHashCode;
//@Data自己生成equals和hashcode
@Data
//不写@EqualsAndHashCode(callSuper = true)可能会出现问题
@EqualsAndHashCode(callSuper = true)
public class ControllerException extends RuntimeException{
    /**
     * 异常码
     * @see ControllerErrorCodeConstants
     */
    private Integer code;
    /**
     * 异常信息
     */
    private String message;


    //为了序列化
    public ControllerException() {

    }
    public ControllerException(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public ControllerException(ErrorCode errorCode) {
        this.code = errorCode.getCode();
        this.message = errorCode.getMessage();
    }
}
